{extend name="layout" /}
{block name="content"}
<div class="row">
  <div class="col-xs-3">
    <form>
      <div class="input-group input-group-sm demoTable">
          <input type="text" class="form-control input-sm" name="keywords" id="demoReload" autocomplete="off"><!-- keywords -->
          <span class="input-group-btn">
            <button class="btn btn-info btn-flat layui-btn" data-type="reload">搜  索</button>
          </span>
      </div>
    </form>
  </div>
  <div class="col-xs-9" style="text-align: right">
    <button type="button" class="btn btn-success btn-sm cocoModal" isForm url="{:url('add')}" title="新增项目" fixat="1"><i class="fa fa-plus"></i> 新增</button>
    <button type="button" class="btn btn-info btn-sm export" title="奖励金列表"><i class="fa fa-edit"></i> 数据导出</button>
  </div>
</div>
<table class="layui-table" lay-data="{height: 'full-75', cellMinWidth: 80, page: true, id:'lists',limit:30, url:'{:url('data_show_where',['whereData'=>$whereData])}'}" lay-filter="lists">
  <thead>
    <tr class="layui-colla-content">
      <th lay-data="{type:'checkbox'}">ID</th>
      <th lay-data="{field:'id', sort: true}">ID</th>
      <th lay-data="{field:'realname'}">经纪人名称</th>
      <th lay-data="{field:'clientname'}">客户名称</th>
      <th lay-data="{field:'price'}">奖励金额</th>
      <th lay-data="{field:'statusname'}">状态</th>
      <!-- <th lay-data="{field:'adminuser'}">审核者</th> -->
      <!-- <th lay-data="{field:'senddate'}">审核时间</th> -->
      <th lay-data="{field:'auditdate'}">确认时间</th>
      <th lay-data="{field:'adddate'}">创建时间</th>
      {in name="$uinfo.roleid" value="1,4"}<th lay-data="{fixed: 'right', width:150, align:'center', toolbar: '#barDemo'}">操作</th>{/in}
  </thead>
</table>
<script type="text/html" id="barDemo">
  <!-- <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a> -->
  <!-- <a class="layui-btn layui-btn-xs layui-btn-green" lay-event="audit">发放</a> -->
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
{/block}
{block name="script"}
<script type="text/javascript">
  layui.use('table', function(){
    var table = layui.table;
    var $ = layui.$, active = {
      reload: function(){
        var demoReload = $('#demoReload');
        //执行重载
        table.reload('lists', {
          page: {
            curr: 1 //重新从第 1 页开始
          }
          ,where: {
            key: {
              keywords: demoReload.val()
            }
          }
        });
      }
    };
    $('.demoTable .layui-btn').on('click', function(){
      var type = $(this).data('type');
      active[type] ? active[type].call(this) : '';
    });
  });
  function audit(data){
    layer.confirm('确定已经发放了吗？', function() {
      $.post('/admin/memberbouns/audit', {ids: data.id}, function(datajson) {
        if (datajson.status == 1) {
          layer.msg('发放成功！');
        }else{
          layer.msg(datajson.msg ? datajson.msg : '操作失败！');
        }
      });
    })
  }
</script>
{/block}